package cn.bocweb.spinning.view.dialog;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Button;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.bocweb.spinning.R;

/**
 * Created by chenchangxing on 16/1/28.
 */
public class TimeStopDialog extends AlertDialog {

    OnFinishListener onFinishListener;

    @Bind(R.id.time_stop_btn)
    Button timeStopBtn;

    public TimeStopDialog(Context context) {
        super(context);
    }

    protected TimeStopDialog(Context context, int theme) {
        super(context, theme);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.window_time_stop);
        setCancelable(false);
        ButterKnife.bind(this);
    }

    @Override
    protected void onStart() {
        super.onStart();

        timeStopBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onFinishListener.click();
            }
        });
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    public interface OnFinishListener {
        void click();
    }

    public void setOnFinishListener(OnFinishListener onFinishListener) {
        this.onFinishListener = onFinishListener;
    }

    public void setBtnText(int time) {
        timeStopBtn.setText("交卷(" + time + ")");
    }
}
